<%@ page contentType="text/html" pageEncoding="UTF-8"%>
<%@ taglib uri="http://www.springframework.org/tags" prefix="spring"%>
<%@ taglib prefix="c" uri="http://java.sun.com/jsp/jstl/core"%>
<%@ taglib prefix="form" uri="http://www.springframework.org/tags/form" %>
<%@ taglib prefix="fmt" uri="http://java.sun.com/jsp/jstl/fmt" %>

<div id="wrapper">
    <div class="main clearfix">
        <div class="col_730">        
            <div align="center">
                <h2>Add Session</h2>
                <table border="0" width="100%">
                    <form:form action="${baseUrl}/cp/savesession.html" method="POST" commandName="sessionFormAdd">
                        <tr>
                            <td>Year</td>
                            <td><form:input path="year" value="" size="30"/></td>
                            <td><form:errors path="year" cssClass="error"/></td>
                        </tr>
                        <tr>
                            <td align="left" width="20%">Semester </td>
                            <td align="left" width="40%">
                                <form:select path="semester">
                                    <form:option value="1" label="1st semester"/>
                                    <form:option value="2" label="2nd semester"/>
                                </form:select>
                            </td>
                            <td align="left"><form:errors path="semester" cssClass="error"/></td>
                        </tr>

                        <tr>
                            <td><form:hidden path="id" value="0"/></td>
                            <td align="left">
                                <input type="submit" value="Add"/>
                                <input type="button" onclick="formCancel('${baseUrl}/cp/sessions.html');" value="Cancel"/>
                            </td>
                            <td align="left"></td>
                        </tr>
                    </form:form>
                </table>
            </div> 
        </div> 
    </div>
</div>
<script type="text/javascript">
    $(document).ready(function() {
        sz_Response = "${sz_Response}";
        if (sz_Response !== "")
        {
            alert(sz_Response);
        }

       $('#year').datepicker({
            showOn: "button",
            buttonImage: "${assetsUrl}/images/calendar.gif",
            buttonImageOnly: true,
            changeYear: true,

             onClose: function() {
                    var iYear = $("#ui-datepicker-div .ui-datepicker-year :selected").val();
                    var iNextYear = parseInt(iYear) + 1;
                    $(this).val(iYear+'-'+iNextYear);
             },

             beforeShow: function() {
               if ((selDate = $(this).val()).length > 0) 
               {
                      iYear = selDate.substring(0, selDate.length - 5);
                      $(this).datepicker('option', 'defaultDate', new Date(iYear, 1));
                      iNextYear = parseInt(iYear) + 1;
                      $(this).val(iYear+'-'+iNextYear);
               }
            }
      });
    });
</script>